<%@ page import="com.party.core.model.system.TargetType" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="../include/tag.jsp" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>
        ${member.id == null ? '添加' : '编辑'}用户
    </title>
    <%@include file="../include/commonFile.jsp" %>
    <script src="//api.map.baidu.com/api?v=2.0&ak=2izIwlMmDVH737ms8m4Y8uHsoxtEIR65"></script>
    <link rel="stylesheet" href="${ctx}/css/common/list.css">
    <link rel="stylesheet" href="${ctx}/css/ui/system/member/member_form.css">
    <script type="text/javascript" src="${ctxStatic}/typeahead/typeahead.bundle.js"></script>
    <style>
        .member-cell {
            display: -webkit-box;
            display: -webkit-flex;
            display: -moz-box;
            display: -ms-flexbox;
            display: flex;
            width: 100%;
            -webkit-box-align: center;
            -webkit-align-items: center;
            -moz-box-align: center;
            -ms-flex-align: center;
            align-items: center;
            -webkit-box-pack: start;
            -webkit-justify-content: flex-start;
            -moz-box-pack: start;
            -ms-flex-pack: start;
            justify-content: flex-start;
        }

        .member-cell .member-logo {
            display: inline-block;
            /*float: left;*/
            width: 30px;
            height: 30px;
            -webkit-border-radius: 50%;
            border-radius: 50%;
            line-height: 50px;
            -webkit-background-size: cover;
            background-size: cover;
            background-position: center;
            background-repeat: no-repeat;
        }

        .member-cell .member-name {
            -webkit-box-flex: 1;
            -moz-box-flex: 1;
            -ms-flex: 1;
            -webkit-flex: 1;
            flex: 1;
            line-height: 30px;
            padding-left: 5px;
            display: inline-block;
            text-align: left;
        }

        .member-cell .member-logo-img {
            width: 30px;
            height: 30px;
            -webkit-border-radius: 50%;
            border-radius: 50%;
        }

        .layui-form-label {
            width: 75px !important;
        }
    </style>
</head>
<body>
<!--头部-->
<%@include file="../include/header.jsp" %>
<div class="index-outside">
    <%@include file="../include/sidebar.jsp" %>
    <!--内容-->
    <section>
        <div class="section-main">
            <!-- 正文请写在这里 -->
            <div class="layui-tab layui-tab-brief">
                <div class="layui-tab-content">
                    <%--基本信息--%>
                    <div class="layui-tab-item layui-show">
                        <form id="myForm" class="layui-form mt20" method="post"
                              action="${ctx}/member/membermgmt/xzgs/saveOrUpdate.do">
                            <input type="hidden" name="id" value="${member.id}"/>
                            <input type="hidden" name="pmId" value="${pmId}"/>
                            <table>
                                <tr>
                                    <td>
                                        <div class="layui-form-item">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">推荐人</label>
                                                <c:if test="${tjMember!=null}">
                                                    <div class="member-cell layui-input-inline"
                                                         onclick="openDialogShow('用户名片','${ctx}/system/member/memberView.do?id=${tjMember.id}','400px','470px')">
                                                        <div class="member-logo common-img">
                                                            <img src="<c:if test="${tjMember.logo!= null}">${tjMember.logo}?imageMogr2/auto-orient/crop/126x126</c:if>"
                                                                 alt="" onerror="txz.errImg(this)"
                                                                 onload="txz.imgLoad(this)">
                                                        </div>
                                                        <div class="member-name ellipsis-1">
                                                            <a class="blue" title="${tjMember.realname}"
                                                               href="javascript:void(0);">${tjMember.realname}</a>
                                                        </div>
                                                    </div>
                                                </c:if>
                                                <c:if test="${tjMember==null}">
<%--                                                    <div class="layui-input-inline">
                                                        <input type="hidden" id="tjMemberId" name="tjMemberId" value="">
                                                        <input class="layui-input" id="tjMemberMobile"
                                                               name="tjMemberMobile"
                                                               placeholder="请输入推荐人手机号"
                                                               value="">
                                                    </div>--%>
                                                    <div class="layui-form-mid layui-word-aux">无推荐人</div>
                                                </c:if>
                                            </div>
                                        </div>
                                    </td>
                                    <td>
                                        <div class="layui-form-item">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">邮箱</label>
                                                <div class="layui-input-inline">
                                                    <input class="layui-input" lay-verify="email" id="email"
                                                           name="email"
                                                           placeholder="邮箱"
                                                           value="${memberInfo.email}">
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                </tr>

                                <tr>
                                    <td>
                                        <div class="layui-form-item">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">编号</label>
                                                <div class="layui-input-inline">
                                                    <input class="layui-input" lay-verify="userSerial" id="userSerial"
                                                           name="userSerial"
                                                           placeholder="编号"
                                                           value="${memberInfo.userSerial}">
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                    <td>
                                        <div class="layui-form-item">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">公司名 </label>
                                                <div class="layui-input-inline">
                                                    <input class="layui-input" name="company" id="company"
                                                           placeholder="公司名"
                                                           lay-verify="company"
                                                           value="${member.company}">
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                </tr>

                                <tr>
                                    <td>
                                        <div class="layui-form-item">
                                            <label class="layui-form-label">头像</label>
                                            <div class="cover-content">
                                                <input type="hidden" name="logo" id="pic" lay-verify="logo"
                                                       value="${(member.logo == null || empty member.logo) ? 'http://txzapp-10052192.image.myqcloud.com/1490783498894':member.logo}"/>
                                                <c:if test="${member == null || empty member.logo}">
                                        <span id="cover-img" class="round-img"
                                              style="background-image:url(http://txzapp-10052192.image.myqcloud.com/1490783498894)"></span>
                                                </c:if>
                                                <c:if test="${member != null && not empty member.logo}">
                                        <span id="cover-img" class="round-img"
                                              style="background-image:url('${member.logo}')"></span>
                                                </c:if>
                                                <a class="layui-btn layui-btn-danger" id="sel_pic_img">+添加头像</a>
                                            </div>
                                        </div>
                                    </td>
                                    <td>
                                        <div class="layui-form-item">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">职务</label>
                                                <div class="layui-input-inline">
                                                    <input class="layui-input" name="jobTitle" id="jobTitle"
                                                           lay-verify="jobTitle"
                                                           placeholder="职务" value='${member.jobTitle}'/>
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div class="layui-form-item">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">行业</label>
                                                <div class="layui-input-inline">
                                                    <select lay-verify="industryParent" lay-filter="industryParent" id="inParent">
                                                        <option value="">选择行业分类</option>
                                                        <c:forEach var="industry" items="${industries}">
                                                            <option value="${industry.id}" ${idParent == industry.id?'selected="selected"' : ''}>${industry.name}</option>
                                                        </c:forEach>
                                                    </select>
                                                </div>
                                                <div class="layui-input-inline">
                                                    <select name="industry" lay-verify="industry" id="industry">
                                                        <option value="">选择行业</option>
                                                    </select>
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                    <td>
                                        <div class="layui-form-item">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">社团职务</label>
                                                <div class="layui-input-inline">
                                                    <input class="layui-input" name="leagueJob" id="leagueJob"
                                                           lay-verify="leagueJob"
                                                           placeholder="社团职务" value='${memberInfo.leagueJob}'/>
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div class="layui-form-item">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">姓名<span
                                                        class="f-verify-red">*</span></label>
                                                <div class="layui-input-inline">
                                                    <input class="layui-input" name="realname" id="realname"
                                                           lay-verify="realname"
                                                           placeholder="姓名" value='${member.realname}'/>
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                    <td>
                                        <div class="layui-form-item">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">爱好</label>
                                                <div class="layui-input-inline" style="width: 300px">
                                                    <input class="layui-input" lay-verify="hobby" id="hobby"
                                                           name="hobby"
                                                           placeholder="爱好"
                                                           value="${memberInfo.hobby}">
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div class="layui-form-item">
                                            <div class="layui-inline">
                                                <label class="layui-form-label" style="width: 90px">性别</label>
                                                <div class="layui-input-inline">
                                                    <input type="radio" name="sex" value="1" title="男"
                                                    ${member.sex != null && member.sex == '1' ? 'checked="checked"' : ''}>
                                                    <input type="radio" name="sex" value="0" title="女"
                                                    ${member.sex == null || member.sex == '0' ? 'checked="checked"' : ''}>
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                    <td>
                                        <div class="layui-form-item">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">简介</label>
                                                <div class="layui-input-inline" style="width: 300px;height: 95px;">
                                                    <textarea name="synopsis" style="resize:none" id="synopsis"
                                                              placeholder="简介"
                                                              lay-verify="synopsis"
                                                              class="layui-textarea">${memberInfo.synopsis}</textarea>
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div class="layui-form-item">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">手机号<span
                                                        class="f-verify-red">*</span></label>
                                                <div class="layui-input-inline">
                                                    <input class="layui-input typeahead" id="phone" name="mobile"
                                                           placeholder="手机号"
                                                           lay-verify="mobile"
                                                           value="${member.mobile}">
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                    <td>
                                        <div class="layui-form-item">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">微信号</label>
                                                <div class="layui-input-inline">
                                                    <input class="layui-input" name="wechatNum" id="wechatNum"
                                                           placeholder="微信号"
                                                           value="${member.wechatNum}">
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div class="layui-form-item">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">主要业务</label>
                                                <div class="layui-input-inline" style="width: 400px">
                                                    <input class="layui-input" id="mainBus" name="mainBus"
                                                           placeholder="主要业务"
                                                           value="${memberInfo.mainBus}">
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                    <td>
                                        <div class="layui-form-item">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">所需资源</label>
                                                <div class="layui-input-inline" style="width: 300px">
                                                    <input class="layui-input" name="wantRes" id="wantRes"
                                                           placeholder="所需资源"
                                                           value="${member.wantRes}">
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div class="layui-form-item">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">城市</label>
                                                <div class="layui-input-inline">
                                                    <select lay-filter="province" id="arParent">
                                                        <option value="">选择省份/直辖市</option>
                                                        <c:forEach var="area" items="${areas}">
                                                            <option value="${area.id}" ${arParent == area.id?'selected="selected"' : ''}>${area.name}</option>
                                                        </c:forEach>
                                                    </select>
                                                </div>
                                                <div class="layui-input-inline">
                                                    <select name="city" id="city" lay-filter="city2">
                                                        <option value="">选择城市</option>
                                                    </select>
                                                </div>
                                                <div class="layui-input-inline">
                                                    <select name="district" id="district">
                                                        <option value="">选择区(县)</option>
                                                    </select>
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                    <td>
                                        <div class="layui-form-item">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">宣言</label>
                                                <div class="layui-input-inline" style="width: 300px; height: 50px">
                                                    <textarea name="manifesto" style="resize:none" id="manifesto"
                                                              placeholder="宣言"
                                                              lay-verify="manifesto"
                                                              class="layui-textarea">${memberInfo.manifesto}</textarea>
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div class="layui-form-item">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">详细地址</label>
                                                <div class="layui-input-inline">
                                                    <input class="layui-input" name="address" id="address"
                                                           style="width: 400px;"
                                                           lay-verify="address"
                                                           placeholder="详细地址"
                                                           value="${memberInfo.address}">
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2">
                                        <div class="layui-form-item">
                                            <%@include file="xzgsmemberAddressMap.jsp"%>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div class="layui-form-item">
                                            <div class="layui-inline">
                                                <label class="layui-form-label"></label>
                                                <div class="layui-input-inline">
                                                    <a href="javascript:void(0)" class="layui-btn layui-btn-danger"
                                                       lay-submit
                                                       lay-filter="myForm">立即提交</a>
                                                    <a href="${ctx}/member/membermgmt/list.do"
                                                       class="layui-btn layui-btn-primary">取消</a>
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                            </table>
                        </form>
                    </div>
                </div>
            </div>
        </div><!--底部-->
        <%@include file="../include/footer.jsp" %>
    </section>
</div>
<script>
    $(function () {
        $('#sel_pic_img').click(function () {
            txz.openSelImg({
                min: 1,
                max: 1,
                info: '建议尺寸：120x120',
                type: '<%=TargetType.LOGO.getCode()%>',
                cb: function (imgs) {
                    $('#cover-img').css('background-image', 'url(' + imgs[0].path + ')');
                    $('#pic').val(imgs[0].path);
                }
            })
        })

        var form, laydate, element;
        var thMember = {}, thSel = false, thSel_tj = false, thMember_tj = {};
        var cityVal = "";
        layui.use(['form', 'laydate', 'element'], function () {
            form = layui.form, laydate = layui.laydate, element = layui.element;

            if ('${city}' != "") {
                loadCityData('${arParent}', '${city}');
                loadDistrictData('${city}', '${memberInfo.district}');
            }
            if ('${industryId}' != "") {
                loadIndustryData('${idParent}', '${industryId}');
            }
            //初始化地图控件
            txz.Map.init({
                layForm: form,
                data: {
                    cityId: '${memberInfo.hCityId}',
                    areaInput: '${memberInfo.hArea}',
                    place: '${memberInfo.hPlace}',
                    lat: '${memberInfo.hLat}',
                    lng: '${memberInfo.hLng}',
                    cCityId: '${memberInfo.cCityId}',
                    cAreaInput: '${memberInfo.cArea}',
                    cPlace: '${memberInfo.cPlace}',
                    clat: '${memberInfo.cLat}',
                    clng: '${memberInfo.cLng}'
                }
            });

            // 城市
            form.on('select(province)', function (data) {
                $("#city").html("");
                var cityId = data.value;
                loadCityData(cityId);

                $("#district").html("");
                loadDistrictData(cityVal);
            });
            // 城市
            form.on('select(city2)', function (data) {
                $("#district").html("");
                var cityId = data.value;
                loadDistrictData(cityId);
            });

            // 行业
            form.on('select(industryParent)', function (data) {
                $("#industry").html("");
                var industryId = data.value;
                loadIndustryData(industryId, '');
            });



            //自定义验证规则
            form.verify({
                realname: function (value) {
                    if (!value) {
                        return '姓名不能为空';
                    }
                    if (value.length > 40) {
                        return "姓名长度大于40";
                    }
                },
                mobile: function (value) {
                    if (!util.isValid(value)) {
                        return '请填写手机号';
                    }
                    if (value != "" && !util.checkMobile(value)) {
                        return "请填写正确格式的手机号码";
                    } else if (value != "" && util.checkMobile(value)) {
                        var memberId = $("input[name='id']").val();
                        var bl = false;
                        $.ajax({
                            type: 'POST',
                            async: false, // 使用同步的方法
                            data: {
                                mobile: value,
                                memberId: memberId
                            },
                            dataType: 'json',
                            success: function (result) {
                                var data = result.data;
                                bl = data;
                            },
                            url: "${ctx}/member/membermgmt/xzgs/checkPartnerUserMobile.do"
                        });

                        if (!bl) {
                            return "手机号已存在";
                        }
                    }
                },
                jobTitle: function (value) {
                    if (util.isValid(value) && value.length > 20) {
                        return "客户职务长度大于20";
                    }
                },
                leagueJob: function (value) {
                    if (util.isValid(value) && value.length > 20) {
                        return "社团职务长度大于20";
                    }
                },
                userSerial: function (value) {
                    if (util.isValid(value)) {
                        if (value.length > 10) {
                            return "编号长度大于10";
                        }
                    }
                },
                company: function (value) {
                    if (value.length > 40) {
                        return "公司名长度大于40";
                    }
                },
                email: function (value) {
                    if (util.isValid(value) && (!util.checkEmail(value))) {
                        return "请填写正确的的邮箱";
                    }
                    if (util.isValid(value) && value.length > 30) {
                        return "邮箱长度大于30";
                    }
                },
                address: function (value) {
                    if (util.isValid(value) && value.length > 50) {
                        return "详细地址长度大于50";
                    }
                },
                hobby: function (value) {
                    if (util.isValid(value) && value.length > 30) {
                        return "爱好长度大于30";
                    }
                },
                manifesto: function (value) {
                    if (util.isValid(value) && value.length > 50) {
                        return "宣言长度大于50";
                    }
                },
                synopsis: function (value) {
                    if (util.isValid(value) && value.length > 50) {
                        return "简介长度大于50";
                    }
                }
            });

            function loadCityData(cityId, area) {
                $.ajax({
                    type: 'POST',
                    async: false, // 使用同步的方法
                    data: {
                        cityId: cityId
                    },
                    dataType: 'json',
                    success: function (res) {
                        var data = res
                        var array = new Array();
                        for (var i = 0; i < data.length; i++) {
                            if (i == 0) {
                                cityVal = data[i].id;
                            }
                            if (area == data[i].id) {
                                cityVal = data[i].id;
                                array.push("<option value = '" + data[i].id + "' selected='selected'>" + data[i].name + "</option>");
                            } else {
                                array.push("<option value = '" + data[i].id + "'>" + data[i].name + "</option>");
                            }
                        }
                        $("#city").append(array.join(""));
                        form.render('select');
                    },
                    url: "${ctx}/system/member/getCityByParentId.do"
                });
            }

            function loadDistrictData(city, area) {
                $.post("${ctx}/system/member/getCityByParentId.do", {
                    "cityId": city
                }, function (data) {
                    var array = new Array();
                    for (var i = 0; i < data.length; i++) {
                        if (area == data[i].id) {
                            array.push("<option value = '" + data[i].id + "' selected='selected'>" + data[i].name + "</option>");
                        } else {
                            array.push("<option value = '" + data[i].id + "'>" + data[i].name + "</option>");
                        }
                    }
                    $("#district").append(array.join(""));
                    form.render('select');
                });
            }


            //监听提交
            form.on('submit(myForm)', function (data) {
                txz.submitObject(data.elem, function (callBack) {
                    var action = $("#myForm").attr("action");
                    $.post(action, $('#myForm').serialize(), function (res) {
                        typeof callBack === 'function' && callBack();
                        if (res.success) {
                            util.layerMsgSuccess("基本信息提交成功", function () {
                                var ref = '';
                                if (document.referrer.length > 0) {
                                    ref = document.referrer;
                                }
                                if (ref.length > 0) {
                                    if (ref.indexOf("pageNo") != -1) {
                                        location.href = ref;
                                    } else {
                                        ref = ref + "?pageNo=${pageNo}"
                                        location.href = ref;
                                    }
                                } else {
                                    location.href = "${ctx}/member/membermgmt/list.do";
                                }
                            });
                        } else {
                            util.layerMsgError(res.description)
                        }
                    });
                })
                return false;
            });

            $('#phone').typeahead({
                hint: false,
                highlight: true,
                minLength: 1
            }, {
                name: 'phone',
                display: 'mobile',
                async: true,
                templates: {
                    suggestion: function (member) {
                        return '<a href="javascript:void(0);"><span data-id="' + member.id + '" class="t-user-logo" style="background-image: url(' + member.logo
                            + '),url(${ctx}/image/def_user_logo.png)"></span><span class="t-user-name">' + (member.realname || '') + (member.mobile || '') + '</span></a>';
                    }
                },
                source: function (q, syn, aja) {
                    _findMember('phone', q, aja);
                }
            });

            $('#tjMemberMobile').typeahead({
                hint: false,
                highlight: true,
                minLength: 1
            }, {
                name: 'tjMemberMobile',
                display: 'tjMemberMobile',
                async: true,
                templates: {
                    suggestion: function (member) {
                        return '<a href="javascript:void(0);"><span data-id="' + member.id + '" class="t-user-logo" style="background-image: url(' + member.logo
                            + '),url(${ctx}/image/def_user_logo.png)"></span><span class="t-user-name">' + (member.realname || '') + (member.mobile || '') + '</span></a>';
                    }
                },
                source: function (q, syn, aja) {
                    _findPartnerMember('phone', q, aja);
                }
            });

            $('#tjMemberMobile').bind('typeahead:select', function (ev, suggestion) {
                thMember_tj = suggestion;
                thSel_tj = true;
                $(ev.currentTarget).blur();
            });
            $('#tjMemberMobile').blur(function () {
                if (thSel_tj) {
                    $('#tjMemberId').val(thMember_tj.id);
                    $('#tjMemberMobile').val(thMember_tj.mobile);

                } else {
                    if (thMember_tj.id) {
                        thMember_tj = {};
                        $('#tjMemberId').val("");
                        $('#tjMemberMobile').val("");
                    }
                }
                form.render();
                thSel_tj = false;
            });

            $('.typeahead').bind('typeahead:select', function (ev, suggestion) {
                thMember = suggestion;
                thSel = true;
                $(ev.currentTarget).blur();
            });
            $('.typeahead').blur(function () {
                if (thSel) {
                    _fillInfoById(thMember.id || '');
                } else {
                    if (thMember.id) {
                        thMember = {};
                        clearForm();
                    }
                }
                thSel = false;
            });

            function _findMember(type, q, cb) {
                $.ajax({
                    url: "${ctx}/system/member/findMemberByPhoneOrName.do",
                    type: "post",
                    dataType: "json",
                    data: {
                        property: type,
                        value: q
                    },
                    success: function (ret) {
                        cb(ret.data);
                    }
                });
            }

            // 联动行业
            function loadIndustryData(inParent, industryId) {
                var array = new Array();
                if (inParent == "") {
                    $("#industry").html("");
                    array.push("<option value=''>选择行业</option>");
                    $("#industry").append(array.join(""));
                    form.render('select');
                } else {
                    $.post("${ctx}/system/member/getIndustryByParentId.do", {
                        "industryId": inParent
                    }, function (data) {
                        for (var i = 0; i < data.length; i++) {
                            if (industryId == data[i].id) {
                                array.push("<option value = '" + data[i].id + "' selected='selected' >" + data[i].name + "</option>");
                            } else {
                                array.push("<option value = '" + data[i].id + "'>" + data[i].name + "</option>");
                            }
                        }
                        $("#industry").append(array.join(""));
                        form.render('select');
                    });
                }
            }

            function _findPartnerMember(type, q, cb) {
                $.ajax({
                    url: "${ctx}/system/member/findPartnerMemberByPhoneOrName.do",
                    type: "post",
                    dataType: "json",
                    data: {
                        property: type,
                        value: q,
                        pmId: $("input[name=pmId]").val()
                    },
                    success: function (ret) {
                        cb(ret.data);
                    }
                });
            }

            function _fillInfoById(id) {
                $.ajax({
                    url: '${ctx}/member/membermgmt/xzgs/getcMemberInfo.do',
                    type: 'POST',
                    dataType: 'JSON',
                    data: {
                        memberId: id
                    },
                    success: function (ret) {
                        var member = ret.data.member;
                        var cMemberInfo = ret.data.cMemberInfo;
                        var arParent = ret.data.arParent;


                        var logo = member.logo || '';
                        var realname = member.realname || '';
                        var phone = member.mobile || '';
                        var company = member.company || '';
                        var jobTitle = member.jobTitle || '';
                        var cityId = member.city || '';
                        var wechatNum = member.wechatNum || '';


                        $("#cover-img").css('background-image', "url('" + logo + "')");
                        $('#pic').val(logo);
                        $("#realname").val(realname);
                        $("#phone").val(phone);
                        $("#company").val(company);
                        $("#jobTitle").val(jobTitle);
                        $("#arParent").val(arParent);
                        $("input[name='id']").val(member.id);
                        $("#wechatNum").val(wechatNum);

                        $("input[name=sex][value=" + member.sex + "]").prop('checked', 'checked');


                        var hobby = cMemberInfo.hobby || '';
                        var synopsis = cMemberInfo.synopsis || '';
                        var manifesto = cMemberInfo.manifesto || '';
                        var address = cMemberInfo.address || '';
                        var district = cMemberInfo.district || '';
                        var email = cMemberInfo.email || '';
                        var userSerial = cMemberInfo.userSerial || '';
                        var leagueJob = cMemberInfo.leagueJob || '';

                        $("#hobby").val(hobby);
                        $("#synopsis").val(synopsis);
                        $("#manifesto").val(manifesto);
                        $("#address").val(address);
                        $("#email").val(email);
                        $("#userSerial").val(userSerial);
                        $("#leagueJob").val(leagueJob);
                        loadCityData(arParent, cityId);
                        loadDistrictData(cityId, district);

                        /*                    form.render('select');
                                            form.render('radio');*/
                        form.render();
                    }
                });
            }

            function clearForm() {
                $("input[name='id']").val("");
                $("#cover-img").css('background-image', "url('" + "http://txzapp-10052192.image.myqcloud.com/1490783498894" + "')");
                $('#pic').val("");
                $(".u-single-upload").show();

                $("#city").html("<option value=''>选择城市</option>");
                $("#industry").html("<option value=''>选择行业</option>");
                /*                form.render('select');
                                form.render('radio');*/
                form.render();
            }
        });
    })

    function openDialogShow(title, url, width, height, target) {
        layer.open({
            type: 2,
            area: [width, height],
            title: title,
            maxmin: false, // 开启最大化最小化按钮
            content: url,
            btn: ['关闭'],
            yes: function (index, layero) {
                setTimeout(function () {
                    top.layer.close(index);
                }, 100);// 延时0.1秒，对应360 7.1版本bug
            }
        });
    }
</script>
<script type="text/javascript">
    txz.initHeader({
        nav: [{
            name: '会员管理',
            href: '${ctx}/member/membermgmt/list.do'
        }, {
            name: '${member.id == null ? '添加' : '编辑'}用户',
            curr: true
        }],
        btns: [{
            name: '返回',
            href: 'javascript:history.back();',
            icon: 'back'
        }]
    });
</script>
</body>
</html>